#include <string.h>

int strncmp(const char *src, const char *dest, size_t count) {
	register char res = 0;

	while (count) {
		if ((res = *src - *dest++) != 0 || !*src++)
			break;
		count--;
	}
	return res;
}

#ifdef _TEST_
#include <stdio.h>

int main() {
	char str[][5] = { "R2D2" , "C3PO" , "R2A6" };
	int n;
	puts("Looking for R2 astromech droids...");
	for (n = 0; n < 3; n++)
		if (strncmp (str[n], "R2xx",2) == 0) {
			printf ("found %s\n",str[n]);
		}
	return 0;
}

#endif
